package com.cai.file.demo;

import java.io.File;
import java.io.FileFilter;

public class ListFileDemo {
    public static void main(String[] args) {
        File f = new File("./");
        File[] files = f.listFiles();
        System.out.println("全部子项：");
        for (File f2 : files
        ) {
            System.out.print(f2.getName() + " ");
        }
        System.out.println();
        //过滤器
        files = f.listFiles(p -> p.getName().contains("a"));
        System.out.println("过滤只含有a的子项：");
        for (File f1 : files
             ) {
            System.out.print(f1.getName()+" ");
        }
    }
}
